Last updated: 2019-03-01

Checks: 4 2

Knit directory: DNASeq/

This reproducible R Markdown analysis was created with workflowr (version 1.2.0). The Report tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

The global environment had objects present when the code in the R Markdown file was run. These objects can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment. Use wflow_publish or wflow_build to ensure that the code is always run in an empty environment.

The following objects were defined in the global environment when these results were created:

Name Class Size
a packageIQR 2.3 Kb
alignMerge cwlStepParam 306.3 Kb
bwa cwlParam 25.2 Kb
bwaAlign cwlStepParam 125.7 Kb
dats packageIQR 2.3 Kb
f1 InputParam 2.8 Kb
f2 InputParam 2.8 Kb
f3 InputParam 2.8 Kb
fastqc cwlParam 13.8 Kb
featureCounts cwlParam 19.4 Kb
fq1 list 832 bytes
fq2 list 832 bytes
fq2ubamJson cwlParam 37.4 Kb
GAlign cwlStepParam 211.9 Kb
geneBody_coverage cwlParam 21.8 Kb
genePredToBed cwlParam 16.5 Kb
gtfToGenePred cwlParam 16.5 Kb
hapCall cwlStepParam 29.6 Kb
hapJson cwlParam 19.3 Kb
inputList list 3.5 Kb
jdCall cwlStepParam 129.5 Kb
jdJson cwlParam 28.3 Kb
markdup cwlParam 21.8 Kb
mc3 cwlStepParam 90.6 Kb
mergeBam cwlParam 18.4 Kb
mergeBamDup cwlStepParam 122.7 Kb
mvOut cwlParam 13.4 Kb
o1 OutputParam 2.3 Kb
o2 OutputParam 2.3 Kb
o2a OutputParam 2.3 Kb
o2b OutputParam 2.3 Kb
o2c OutputParam 2.3 Kb
o3 OutputParam 2.3 Kb
o4 OutputParam 2.4 Kb
o5 OutputParam 2.4 Kb
o6 OutputParam 2.4 Kb
o7 OutputParam 2.3 Kb
o8 OutputParam 2.3 Kb
p1 InputParam 2.8 Kb
p10 InputParam 2.8 Kb
p11 InputParam 2.8 Kb
p12 InputParam 2.8 Kb
p13 InputParam 2.8 Kb
p2 InputParam 2.8 Kb
p3 InputParam 2.8 Kb
p4 InputParam 2.8 Kb
p5 InputParam 2.8 Kb
p6 InputParam 2.8 Kb
p7 InputParam 2.8 Kb
p8 InputParam 2.8 Kb
p9 InputParam 2.8 Kb
paramList list 576 bytes
read_distribution cwlParam 16.6 Kb
req1 list 416 bytes
req2 list 416 bytes
req3 list 416 bytes
rgs list 880 bytes
rnaseq_Sf cwlStepParam 315.6 Kb
rscripts character 816 bytes
RSeQC cwlStepParam 126 Kb
runWDL cwlParam 21.7 Kb
s1 stepParam 19.5 Kb
s2 stepParam 44.2 Kb
s3 stepParam 20.1 Kb
s4 stepParam 19.5 Kb
s5 stepParam 28.1 Kb
s6 stepParam 133.4 Kb
sam2bam cwlParam 13.9 Kb
samples list 592 bytes
samtools_flagstat cwlParam 13.8 Kb
samtools_index cwlParam 14.4 Kb
sortBam cwlParam 13.8 Kb
STAR cwlParam 32.2 Kb
ubam2bamJson cwlParam 16.6 Kb

The command set.seed(20181205) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Untracked files:
    Untracked:  analysis/Rcwl_DNASeq_Align.Rmd
    Untracked:  analysis/Rcwl_DNASeq_Align.Rmd~
    Untracked:  analysis/Rcwl_GATK4.Rmd
    Untracked:  analysis/Rcwl_GATK4.Rmd~
    Untracked:  analysis/Rcwl_MC3.Rmd
    Untracked:  analysis/Rcwl_MC3.Rmd~
    Untracked:  bwaOutput.sam
    Untracked:  code/gatk.R
    Untracked:  code/gatk.R~
    Untracked:  data/fq1_1.fq
    Untracked:  data/fq1_2.fq
    Untracked:  data/fq2_1.fq
    Untracked:  data/fq2_2.fq
    Untracked:  data/normal.bam
    Untracked:  data/normal.bam.bai
    Untracked:  data/normal_1.fq
    Untracked:  data/normal_2.fq
    Untracked:  data/tumor.bam
    Untracked:  data/tumor.bam.bai
    Untracked:  data/tumor_1.fq
    Untracked:  data/tumor_2.fq
    Untracked:  file3f79542e1d70/
    Untracked:  output/BAM/
    Untracked:  output/GATK/
    Untracked:  output/interval.21.interval_list
    Untracked:  output/interval.21.intervals
    Untracked:  output/interval.list~
    Untracked:  output/interval.txt
    Untracked:  output/mc3/
    Untracked:  sample1.bam
    Untracked:  sample1.bam.bai
    Untracked:  temp/DNASeq.Rmd
    Untracked:  temp/DNASeq.Rmd~
    Untracked:  temp/analysis/filed13439812939/
    Untracked:  temp/analysis/temp/
    Untracked:  temp/data/test.1_fastq.gz
    Untracked:  temp/data/test.2_fastq.gz
    Untracked:  temp/output/BAM/
    Untracked:  test.bam
    Untracked:  tmpl1.json

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


Introduction

The GATK4 best practices for germline short variant discovery was implemented with Workflow Description Language (WDL), which is similar to cwl and requires cromwell to run the pipelines.

Here is the details of the pipeline: https://software.broadinstitute.org/gatk/best-practices/workflow?id=11145

Germline short variant discovery (SNPs + Indels)

Germline short variant discovery (SNPs + Indels)

The germline pipelines include 4 steps in WDL, paired fastq to ubam, GATK alignment, variant calling by HaplotypeCaller and joint genotyping. We wrapped the GATK pipelines to 3 steps using Rcwl for different numbers of computing nodes requirements. The wrapped pipelines can help to assign inputs to the input JSON templates and glob results from the cromwell outputs.

First, we need to load the packages and pipelines.

library(Rcwl)
library(RcwlPipelines)
data("GAlign")
data("hapCall")
data("jdCall")

GATK Alignment

We wrapped the steps from raw fastqs to analysis-ready BAM file into GAlign pipeline. Here is the short summary of the pipeline.

short(GAlign)
inputs:
- fastq1
- fastq2
- readGroup
- sampleName
- library
- platunit
- platform
- center
- tmpl1
- wdl1
- tmpl2
- wdl2
- cromwell
outputs:
- bamlog
- outdir
steps:
- fqJson
- fq2ubam
- ubam2bamJson
- align
- mvOut

For the inputList, we need to assign the fastqs files and read groups for each sample. The inputs can be multiple items separated by comma if there are more than one read groups for each sample. The input templates and WDL scripts can be assigned in the paramList and the reference and other GATK bundle files should be changed to your local version of files accordingly in the local json files. The path to the cromwell binary file is also required. Here is an example.

tmpl1 <- system.file(package="RcwlPipelines", "GATK4/seq-format-conversion/paired-fastq-to-unmapped-bam.inputs.json")
tmpl2 <- system.file(package="RcwlPipelines", "GATK4/gatk4-data-processing/processing-for-variant-discovery-gatk4.hg38.wgs.inputs.local.json")
wdl1 <- system.file(package="RcwlPipelines", "GATK4/seq-format-conversion/paired-fastq-to-unmapped-bam.wdl")
wdl2 <- system.file(package="RcwlPipelines", "GATK4/gatk4-data-processing/processing-for-variant-discovery-gatk4.wdl")

inputList <- list(fastq1=list(normal="/home/qhu/workspace/projects/RPipe/data/DNASeq/data/normal_1.fq",
                              tumor="/home/qhu/workspace/projects/RPipe/data/DNASeq/data/tumor_1.fq"),
                  fastq2=list(normal="/home/qhu/workspace/projects/RPipe/data/DNASeq/data/normal_2.fq",
                              tumor="/home/qhu/workspace/projects/RPipe/data/DNASeq/data/tumor_2.fq"),
                  readGroup=list("normal.1", "tumor.1"),
                  sampleName=list("normal", "tumor"),
                  library=list("normal", "tumor"),
                  platunit=list("normal", "tumor"),
                  platform=list("illumina", "illumina"),
                  center=list("rpccc", "rpccc"))
paramList <- list(tmpl1=tmpl1,
                  wdl1=wdl1,
                  tmpl2=tmpl2,
                  wdl2=wdl2,
                  cromwell="/mnt/lustre/users/qhu/software/cromwell-36.jar")
r1 <- runCWLBatch(GAlign, outdir="output/BAM", inputList, paramList,
                  BatchtoolsParam(workers = 2, cluster="sge",
                                  template = "/rpcc/bioinformatics/sge_centos7.tmpl",
                                  resources = list(threads = 16,
                                                   queue = "centos7.q")),
                  stderr="")

The outputs were globbed from the cromwell execution folder.

list.files("output/BAM/normal", recursive = TRUE)
[1] "output/normal.hg38.bai"                        
[2] "output/normal.hg38.bam"                        
[3] "output/normal.hg38.bam.md5"                    
[4] "output/normal.hg38.duplicate_metrics"          
[5] "output/normal.hg38.recal_data.csv"             
[6] "processing-for-variant-discovery-gatk4.wdl.log"

HaplotypeCaller

This step takes the BAM files as input and each BAM file will be assigned to different computing node. Also the json template file need to be modified to the correct GATK bundle paths at first.

wdl3 <- system.file(package="RcwlPipelines", "GATK4/gatk4-germline-snps-indels/haplotypecaller-gvcf-gatk4.wdl")
tmpl3 <- system.file(package="RcwlPipelines", "GATK4/gatk4-germline-snps-indels/haplotypecaller-gvcf-gatk4.hg38.inputs.local.json")

bams <- list(normal = normalizePath("output/BAM/normal/output/normal.hg38.bam"),
             tumor = normalizePath("output/BAM/tumor/output/tumor.hg38.bam"))
inputList <- list(bam = bams)
paramList <- list(intervals = normalizePath("output/interval.txt"),
                  cromwell = "/mnt/lustre/users/qhu/software/cromwell-36.jar",
                  wdl = wdl3,
                  tmpl = tmpl3)

r2 <- runCWLBatch(hapCall, outdir="output/GATK", inputList, paramList,
                  BatchtoolsParam(workers = 2, cluster="sge",
                                  template = "/rpcc/bioinformatics/sge_centos7.tmpl",
                                  resources = list(threads = 16,
                                                   queue = "centos7.q")),
                  stderr="")

Here are the outputs:

list.files("output/GATK/normal", recursive = TRUE)
[1] "haplotypecaller-gvcf-gatk4.wdl.log"
[2] "output/normal.hg38.g.vcf.gz"       
[3] "output/normal.hg38.g.vcf.gz.tbi"   

Joint Discovery

The joint genotyping step will combine the gvcf files and then call variants in all samples, so only one computing node is required. Multiple values or files of the samples need to be pasted by comma for each input in the inputList. The paths of the local bundle files are also need to be added to the json template file.

wdl4 <- system.file(package="RcwlPipelines", "GATK4/gatk4-germline-snps-indels/joint-discovery-gatk4-local.wdl")
tmpl4 <- system.file(package="RcwlPipelines", "GATK4/gatk4-germline-snps-indels/joint-discovery-gatk4-local.hg38.wgs.inputs.json")

inputList <- list(sampleName = list(test="normal,tumor"),
                  gvcf = list(test="/home/qhu/workspace/projects/RPipe/data/DNASeq/output/GATK/normal/output/normal.hg38.g.vcf.gz,/home/qhu/workspace/projects/RPipe/data/DNASeq/output/GATK/tumor/output/tumor.hg38.g.vcf.gz"))

paramList <- list(callsetName = "test",
                  intervals = "/home/qhu/workspace/projects/RPipe/data/DNASeq/output/interval.21.interval_list",
                  unpadded_intervals = "/home/qhu/workspace/projects/RPipe/data/DNASeq/output/interval.21.intervals",
                  tmpl = tmpl4,
                  cromwell = "/mnt/lustre/users/qhu/software/cromwell-36.jar",
                  wdl = wdl4)

r3 <- runCWLBatch(jdCall, outdir="output/GATK", inputList, paramList,
                  BatchtoolsParam(workers = 1, cluster="sge",
                                  template = "/rpcc/bioinformatics/sge_centos7.tmpl",
                                  resources = list(threads = 16,
                                                   queue = "centos7.q")),
                  stderr="")

Here are the final outputs:

list.files("output/GATK/test", recursive = TRUE)
[1] "joint-discovery-gatk4-local.wdl.log"        
[2] "output/out.intervals"                       
[3] "output/test.variant_calling_detail_metrics" 
[4] "output/test.variant_calling_summary_metrics"
[5] "output/test.vcf.gz"                         
[6] "output/test.vcf.gz.tbi"                     


sessionInfo()
R version 3.5.2 Patched (2018-12-31 r75935)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS release 6.4 (Final)

Matrix products: default
BLAS: /home/qhu/usr/R-3.5/lib64/R/lib/libRblas.so
LAPACK: /home/qhu/usr/R-3.5/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] RcwlPipelines_0.99.0 testthat_2.0.1       BiocStyle_2.10.0    
 [4] rmarkdown_1.11       knitr_1.21           usethis_1.4.0       
 [7] devtools_2.0.1       Rcwl_0.99.14         S4Vectors_0.20.1    
[10] BiocGenerics_0.28.0  yaml_2.2.0          

loaded via a namespace (and not attached):
 [1] colorspace_1.4-0    rprojroot_1.3-2     fs_1.2.6           
 [4] rstudioapi_0.9.0    roxygen2_6.1.1      remotes_2.0.2      
 [7] xml2_1.2.0          pkgload_1.0.2       jsonlite_1.6       
[10] workflowr_1.2.0     shiny_1.2.0         DiagrammeR_1.0.0   
[13] BiocManager_1.30.4  readr_1.3.1         compiler_3.5.2     
[16] backports_1.1.3     assertthat_0.2.0    lazyeval_0.2.1     
[19] cli_1.0.1           later_0.8.0         visNetwork_2.0.5   
[22] htmltools_0.3.6     prettyunits_1.0.2   tools_3.5.2        
[25] igraph_1.2.4        gtable_0.2.0        glue_1.3.0         
[28] dplyr_0.8.0.1       batchtools_0.9.11   rappdirs_0.3.1     
[31] Rcpp_1.0.0          rgexf_0.15.3        xopen_1.0.0        
[34] debugme_1.1.0       xfun_0.5            stringr_1.4.0      
[37] ps_1.3.0            mime_0.6            XML_3.98-1.17      
[40] scales_1.0.0        hms_0.4.2           promises_1.0.1     
[43] RColorBrewer_1.1-2  memoise_1.1.0       gridExtra_2.3      
[46] ggplot2_3.1.0       downloader_0.4      rcmdcheck_1.3.2    
[49] stringi_1.3.1       highr_0.7           Rook_1.1-1         
[52] desc_1.2.0          checkmate_1.9.1     pkgbuild_1.0.2     
[55] BiocParallel_1.16.6 rlang_0.3.1         pkgconfig_2.0.2    
[58] commonmark_1.7      evaluate_0.13       purrr_0.3.0        
[61] htmlwidgets_1.3     processx_3.2.1      tidyselect_0.2.5   
[64] plyr_1.8.4          magrittr_1.5        bookdown_0.9       
[67] R6_2.4.0            base64url_1.4       pillar_1.3.1       
[70] withr_2.1.2         tibble_2.0.1        crayon_1.3.4       
[73] viridis_0.5.1       progress_1.2.0      grid_3.5.2         
[76] data.table_1.12.0   git2r_0.24.0        callr_3.1.1        
[79] influenceR_0.1.0    digest_0.6.18       xtable_1.8-3       
[82] tidyr_0.8.2         httpuv_1.4.5.1      brew_1.0-6         
[85] munsell_0.5.0       viridisLite_0.3.0   sessioninfo_1.1.1